package com.hziee.mail.controller;

import com.hziee.mail.model.UserInfoEntity;
import com.hziee.mail.service.UserInfoService;
import com.hziee.mail.util.FormatReturn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @author ZX
 */
@RestController
@RequestMapping("/user")
public class UserInfoController extends FormatReturn {

    @Autowired
    private UserInfoService userInfoService;

    @GetMapping("/login")
    public String login(HttpServletResponse response, String phone, String pwd) {
        UserInfoEntity userInfoEntity = userInfoService.login(phone, pwd);
        if (userInfoEntity != null) {
            return ajaxReturn(response, 1, "success", userInfoEntity);
        } else {
            return ajaxReturn(response, 1, "fail", null);
        }
    }

}
